package com.kgc.service.impl;

import com.kgc.dao.DeliveryInfoMapper;
import com.kgc.dao.DeliveryInfoMapper_wzl;
import com.kgc.dao.OrderMapper;
import com.kgc.dao.OrderMapper_wzl;
import com.kgc.pojo.DeliveryInfo;
import com.kgc.pojo.Order;
import com.kgc.service.GetOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class GetOrderInfo_wzlServiceImpl implements GetOrderInfoService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private OrderMapper_wzl orderMapper_wzl;

    @Autowired
    private DeliveryInfoMapper deliveryInfoMapper;

    @Autowired
    private DeliveryInfoMapper_wzl deliveryInfoMapper_wzl;

    /*获取订单列表*/
    @Cacheable(value = "order",key = "getOrderInfo")
    public List<Order>  getorderinfo(){
        return orderMapper_wzl.getOrderInfo_wzl();
    }

    /*删除订单信息*/
    @CacheEvict(value = "order",allEntries = true)
    public int deleOrderinfo(int id){
        return orderMapper.deleteByPrimaryKey(id);
    }
    /*删除传递的订单信息*/
    @CacheEvict(value = "order",allEntries = true)
    public int deleDeliveryInfo(int id){
        return deliveryInfoMapper.deleteByPrimaryKey(id);
    }
    /*更新order表数据*/
    @CacheEvict(value = "order",allEntries = true)
    public int updateOrderInfo_wzl(String ordernum ,String ticketname,String money,Integer id){
        return orderMapper_wzl.updateOrderInfo_wzl(ordernum,ticketname,money,id);
    }
    /*更新deliveryinfo表数据*/
    public int updateDeliveryinfo(String deliveryways ,String receiveraddress,String receiver,String phone,String carriage,Integer id){
        return deliveryInfoMapper_wzl.updateDeliveryinfo_wzl(deliveryways,receiveraddress,receiver,phone,carriage,id);
    }
    /*支付页面插入order表数据*/
    public int inserOrederinfo(Order order){
        return orderMapper_wzl.inserOrderinfo(order);
    }
    /*查询最后的信息*/
    public Order  selectorderLastInfo(){
        return orderMapper_wzl.selectorderLastInfo();
    }
    /*更新时间*/
    public int updatecreatedate(Date createdate,int id ){
        return orderMapper_wzl.updateOrdertime_wzl(createdate,id);
    }
}
